package lore.miniwechat.service.impl;

import lore.miniwechat.entity.Admin;
import lore.miniwechat.mapper.AdminMapper;
import lore.miniwechat.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminMapper mapper;

    @Override
    public List<Admin> getAdmins() {
        return mapper.selectByExample(null);
    }

    @Override
    public void update(String id) {

        Admin admin = mapper.selectByPrimaryKey(id);
        mapper.updateByPrimaryKey(admin);
    }

    @Override
    public void insert(Admin admin) {
        mapper.insertSelective(admin);
    }

    @Override
    public void deleteAdmin(String id) {
        Admin admin= mapper.selectByPrimaryKey(id);
        admin.setState(0);
        mapper.updateByPrimaryKey(admin);
    }
}
